#include<bits/stdc++.h>
using namespace std;
struct ANSWER{
    int ans = 0x3f3f3f3f, qjmin = 0, idx;
};
bool operator < (const ANSWER &a, const ANSWER &b){
    if(a.ans ^ b.ans) return a.ans < b.ans;
    return a.qjmin < b.qjmin;
}
bool operator > (const ANSWER &a, const ANSWER &b){
    if(a.ans ^ b.ans) return a.ans > b.ans;
    return a.qjmin > b.qjmin;
}
const int N = 1.2e4+4;
int n;
bool deleted[N];
typedef pair<int,int> pii;
map<pair<int,int>, int> mp;

struct PQ{
    ANSWER val[N];
    int cnt=0;
    inline void push(ANSWER x){
        val[++cnt] = x;
        int pos = cnt;
        while(pos > 1){
            if(val[pos] < val[pos>>1]){
                swap(val[pos], val[pos>>1]);
                pos >>= 1;
            }else break;
        }
    }
    inline void pop(){
        val[1] = val[cnt--];
        int pos = 1;
        while((pos<<1) <= cnt){
            int son = pos<<1;
            if(son+1<=cnt&&val[son+1]<val[son]) son ++;
            if(val[pos] > val[son]){
                swap(val[pos], val[son]);
                pos = son;
            }else break;
        }
    }
    ANSWER top(){
        return val[1];
    }
};
PQ pq[N];
struct QJ{
    int l,r;
}qj[N];
int main(){
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>n;
    char op;
    int l, r;
    for(int i=1;i<=n;i++){
        // cerr<<i<<'\n';
        cin>>op>>l>>r;
        if(op == 'A'){
            qj[i].l = l, qj[i].r = r;
            mp[{l,r}] = i;
            for(int j=1;j<=i;j++){
                if(deleted[j]) continue;
                ANSWER x;
                int tl = qj[i].l, tr = qj[i].r, sl = qj[j].l, sr = qj[j].r;
                if(tl < sl){
                    swap(tl, sl);
                    swap(tr, sr);
                }
                x.ans = max(0,min(sr,tr)-tl);
                x.qjmin = max(sr,tr) - sl;
                x.idx = i;
                pq[j].push(x);
                x.idx = j;
                pq[i].push(x);
            }
        }else{
            int pre = mp[{l,r}];
            mp[{l,r}] = 0, deleted[pre] = deleted[i] = 1;
            for(int j=1;j<i;j++){
                if(deleted[j]) continue;
                while(deleted[pq[j].top().idx]) pq[j].pop();
            }
        }
        ANSWER x;
        for(int j=1;j<=i;j++){
            if(deleted[j]) continue;
            x = min(x, pq[j].top());
        }
        // cout<<x.ans<<' ';
        cout<<x.qjmin<<'\n';
    }
    return 0;
}